home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1035 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: gregor@netcom.com (Greg Colvin)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: sample auto_ptr template
  5. Date: 11 Apr 1996 14:53:32 GMT
  6. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <gregorDppDEJ.Jpz@netcom.com>
  9. References: <009A0A5CE1159CC0.49802F14@ittpub.nl> <gregorDpoGM2.Hw2@netcom.com>
  10. NNTP-Posting-Host: taumet.eng.sun.com
  11. Apparently-To: comp-std-c++@uunet.uu.net
  12. Content-Length: 1140
  13. X-Lines: 31
  14. Originator: clamage@taumet
  15.  
  16. In article <gregorDpoGM2.Hw2@netcom.com> gregor@netcom.com (Greg Colvin) writes:
  17. >
  18. >Pre April, an auto_ptr silently changed into a null pointer after
  19. >copying, except that trying to copy it was ill-formed.  Post April
  20. >copying is allowed.  Derereferencing a null pointer gives undefined
  21. >behavior, as does dereferencing a pointer to a deleted object, so I
  22. >don't see such a big difference. Given
  23. >   void f(auto_ptr<T>);
  24. >   auto_ptr<T> p(px);
  25. >then before April we had
  26. >   f(p);            // unintentionally ill-formed
  27. >   p->whatever();   // undefined behavior
  28. >and after April we have
  29. >   f(p);            // well-formed
  30. >   p->whatever();   // possibly undefined behavior
  31.  
  32. Silly me. Of course that should be:
  33.    ... Given
  34.       void f(auto_ptr<T>); 
  35.       auto_ptr<T> g();
  36.       auto_ptr<T> p;
  37.    then before April we had
  38.       p = g();              // unintentionally ill-formed
  39.       f(p);               
  40.       p->whatever();        // undefined behavior
  41.    and after April we have
  42.       p = g();              // well formed
  43.       f(p);
  44.       p->whatever();        // possibly undefined behavior
  45.  
  46. I hope I got it right this time :-)
  47.  
  48.  
  49. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  50. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  51. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  52. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  53. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  54.